<template>
  <div class="poo-tracker-create-log">
    <!-- 背景装饰图案 -->
    <div class="background-patterns">
      <!-- 透明度较低的背景图案 -->
      <div class="pattern-group opacity-low">
        <div v-for="i in 20" :key="`low-${i}`" class="pattern-item"></div>
      </div>
      <!-- 正常透明度的背景图案 -->
      <div class="pattern-group opacity-normal">
        <div v-for="i in 20" :key="`normal-${i}`" class="pattern-item"></div>
      </div>
    </div>

    <!-- 主要内容 -->
    <div class="main-content">
      <!-- 标题 -->
      <div class="title">Create Log</div>

      <!-- 类型选择区域 -->
      <div class="type-section">
        <div class="section-title">Type</div>
        
        <!-- 便便类型选项 -->
        <div class="type-options">
          <!-- 类型1: Separate hard lumps -->
          <div 
            class="type-option"
            :class="{ selected: theSelectedType === 1 }"
            @click="onSelectType(1)"
          >
            <div class="option-content">
              <div class="poo-visual type-1">
                <div v-for="i in 7" :key="i" class="poo-dot"></div>
              </div>
              <span class="option-text">Separate hard lumps</span>
            </div>
          </div>

          <!-- 类型2: Lumpy and sausage like -->
          <div 
            class="type-option"
            :class="{ selected: theSelectedType === 2 }"
            @click="onSelectType(2)"
          >
            <div class="option-content">
              <div class="poo-visual type-2">
                <div v-for="i in 9" :key="i" class="poo-dot"></div>
              </div>
              <span class="option-text">Lumpy and sausage like</span>
            </div>
          </div>

          <!-- 类型3: Sausage shaped with cracks -->
          <div 
            class="type-option"
            :class="{ selected: theSelectedType === 3 }"
            @click="onSelectType(3)"
          >
            <div class="option-content">
              <div class="poo-visual type-3">
                <div v-for="i in 12" :key="i" class="poo-dot"></div>
              </div>
              <span class="option-text">Sausage shaped with cracks</span>
            </div>
          </div>

          <!-- 类型4: Smooth and soft -->
          <div 
            class="type-option"
            :class="{ selected: theSelectedType === 4 }"
            @click="onSelectType(4)"
          >
            <div class="option-content">
              <div class="poo-visual type-4">
                <div v-for="i in 8" :key="i" class="poo-dot"></div>
              </div>
              <span class="option-text">Smooth and soft</span>
            </div>
          </div>

          <!-- 类型5: Soft blobs -->
          <div 
            class="type-option"
            :class="{ selected: theSelectedType === 5 }"
            @click="onSelectType(5)"
          >
            <div class="option-content">
              <div class="poo-visual type-5">
                <div v-for="i in 6" :key="i" class="poo-dot"></div>
              </div>
              <span class="option-text">Soft blobs</span>
            </div>
          </div>

          <!-- 类型6: Fluffy pieces -->
          <div 
            class="type-option"
            :class="{ selected: theSelectedType === 6 }"
            @click="onSelectType(6)"
          >
            <div class="option-content">
              <div class="poo-visual type-6">
                <div v-for="i in 10" :key="i" class="poo-dot"></div>
              </div>
              <span class="option-text">Fluffy pieces</span>
            </div>
          </div>

          <!-- 类型7: Watery -->
          <div 
            class="type-option"
            :class="{ selected: theSelectedType === 7 }"
            @click="onSelectType(7)"
          >
            <div class="option-content">
              <div class="poo-visual type-7">
                <div v-for="i in 4" :key="i" class="poo-dot"></div>
              </div>
              <span class="option-text">Watery</span>
            </div>
          </div>
        </div>
      </div>

      <!-- 底部按钮区域 -->
      <div class="bottom-actions">
        <div class="cancel-btn" @click="onCancel">
          Cancel
        </div>
        <div class="create-btn" @click="onCreate">
          <span class="create-text">Create</span>
          <div class="plus-icon">
            <div class="line horizontal"></div>
            <div class="line vertical"></div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang='ts'>
import { ref } from 'vue'

// 选中的便便类型 start
const theSelectedType = ref<number | null>(null)

const onSelectType = (type: number) => {
  theSelectedType.value = type
}
// 选中的便便类型 end

// 取消操作
const onCancel = () => {
  console.log('取消创建日志')
}

// 创建日志
const onCreate = () => {
  if (theSelectedType.value) {
    console.log('创建日志，类型:', theSelectedType.value)
  } else {
    console.log('请先选择便便类型')
  }
}
</script>

<style lang="scss" scoped>
.poo-tracker-create-log {
  width: 375px;
  height: 812px;
  background: #FFFFFF;
  position: relative;
  overflow: hidden;
  border-radius: 60px;
  box-shadow: 0px 4px 20px 0px rgba(0, 0, 0, 0.1);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  
  .background-patterns {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    
    .pattern-group {
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      
      &.opacity-low {
        opacity: 0.1;
        
        .pattern-item {
          position: absolute;
          width: 2px;
          height: 20px;
          background: #8B4513;
          border-radius: 1px;
          
          &:nth-child(1) { top: 50px; left: 30px; transform: rotate(15deg); }
          &:nth-child(2) { top: 80px; left: 60px; transform: rotate(-20deg); }
          &:nth-child(3) { top: 120px; left: 90px; transform: rotate(45deg); }
          &:nth-child(4) { top: 160px; left: 120px; transform: rotate(-10deg); }
          &:nth-child(5) { top: 200px; left: 150px; transform: rotate(30deg); }
          &:nth-child(6) { top: 240px; left: 180px; transform: rotate(-45deg); }
          &:nth-child(7) { top: 280px; left: 210px; transform: rotate(60deg); }
          &:nth-child(8) { top: 320px; left: 240px; transform: rotate(-30deg); }
          &:nth-child(9) { top: 360px; left: 270px; transform: rotate(20deg); }
          &:nth-child(10) { top: 400px; left: 300px; transform: rotate(-60deg); }
          &:nth-child(11) { top: 440px; left: 50px; transform: rotate(40deg); }
          &:nth-child(12) { top: 480px; left: 80px; transform: rotate(-25deg); }
          &:nth-child(13) { top: 520px; left: 110px; transform: rotate(55deg); }
          &:nth-child(14) { top: 560px; left: 140px; transform: rotate(-40deg); }
          &:nth-child(15) { top: 600px; left: 170px; transform: rotate(25deg); }
          &:nth-child(16) { top: 640px; left: 200px; transform: rotate(-55deg); }
          &:nth-child(17) { top: 680px; left: 230px; transform: rotate(35deg); }
          &:nth-child(18) { top: 720px; left: 260px; transform: rotate(-15deg); }
          &:nth-child(19) { top: 760px; left: 290px; transform: rotate(50deg); }
          &:nth-child(20) { top: 100px; left: 320px; transform: rotate(-35deg); }
        }
      }
      
      &.opacity-normal {
        opacity: 1;
        
        .pattern-item {
          position: absolute;
          width: 2px;
          height: 15px;
          background: #D2691E;
          border-radius: 1px;
          
          &:nth-child(1) { top: 70px; left: 45px; transform: rotate(25deg); }
          &:nth-child(2) { top: 110px; left: 75px; transform: rotate(-35deg); }
          &:nth-child(3) { top: 150px; left: 105px; transform: rotate(50deg); }
          &:nth-child(4) { top: 190px; left: 135px; transform: rotate(-20deg); }
          &:nth-child(5) { top: 230px; left: 165px; transform: rotate(40deg); }
          &:nth-child(6) { top: 270px; left: 195px; transform: rotate(-50deg); }
          &:nth-child(7) { top: 310px; left: 225px; transform: rotate(65deg); }
          &:nth-child(8) { top: 350px; left: 255px; transform: rotate(-40deg); }
          &:nth-child(9) { top: 390px; left: 285px; transform: rotate(30deg); }
          &:nth-child(10) { top: 430px; left: 315px; transform: rotate(-65deg); }
          &:nth-child(11) { top: 470px; left: 65px; transform: rotate(45deg); }
          &:nth-child(12) { top: 510px; left: 95px; transform: rotate(-30deg); }
          &:nth-child(13) { top: 550px; left: 125px; transform: rotate(60deg); }
          &:nth-child(14) { top: 590px; left: 155px; transform: rotate(-45deg); }
          &:nth-child(15) { top: 630px; left: 185px; transform: rotate(35deg); }
          &:nth-child(16) { top: 670px; left: 215px; transform: rotate(-60deg); }
          &:nth-child(17) { top: 710px; left: 245px; transform: rotate(40deg); }
          &:nth-child(18) { top: 750px; left: 275px; transform: rotate(-25deg); }
          &:nth-child(19) { top: 120px; left: 305px; transform: rotate(55deg); }
          &:nth-child(20) { top: 160px; left: 335px; transform: rotate(-40deg); }
        }
      }
    }
  }
  
  .main-content {
    position: relative;
    z-index: 10;
    padding: 60px 30px 40px;
    height: 100%;
    display: flex;
    flex-direction: column;
    
    .title {
      font-size: 32px;
      font-weight: 700;
      color: #8B4513;
      text-align: center;
      margin-bottom: 40px;
      letter-spacing: -0.5px;
    }
    
    .type-section {
      flex: 1;
      
      .section-title {
        font-size: 18px;
        font-weight: 600;
        color: #5A5A5A;
        margin-bottom: 20px;
      }
      
      .type-options {
        display: flex;
        flex-direction: column;
        gap: 12px;
        
        .type-option {
          background: #FFFFFF;
          border: 2px solid #E0E0E0;
          border-radius: 20px;
          padding: 16px 20px;
          cursor: pointer;
          transition: all 0.3s ease;
          
          &:hover {
            border-color: #D2691E;
            transform: translateY(-2px);
            box-shadow: 0px 4px 12px 0px rgba(210, 105, 30, 0.15);
          }
          
          &.selected {
            border-color: #8B4513;
            background: #FFF8F0;
            box-shadow: 0px 4px 12px 0px rgba(139, 69, 19, 0.2);
          }
          
          .option-content {
            display: flex;
            align-items: center;
            gap: 16px;
            
            .poo-visual {
              width: 60px;
              height: 40px;
              position: relative;
              display: flex;
              align-items: center;
              justify-content: center;
              flex-wrap: wrap;
              
              .poo-dot {
                width: 6px;
                height: 6px;
                background: #8B4513;
                border-radius: 50%;
                margin: 1px;
                transition: all 0.3s ease;
              }
              
              &.type-1 {
                .poo-dot {
                  width: 8px;
                  height: 8px;
                  margin: 2px;
                }
              }
              
              &.type-2 {
                .poo-dot {
                  width: 7px;
                  height: 7px;
                  border-radius: 3px;
                  margin: 1px;
                }
              }
              
              &.type-3 {
                .poo-dot {
                  width: 5px;
                  height: 8px;
                  border-radius: 2px;
                  margin: 1px;
                }
              }
              
              &.type-4 {
                .poo-dot {
                  width: 8px;
                  height: 6px;
                  border-radius: 4px;
                  margin: 1px;
                }
              }
              
              &.type-5 {
                .poo-dot {
                  width: 10px;
                  height: 8px;
                  border-radius: 5px;
                  margin: 2px;
                }
              }
              
              &.type-6 {
                .poo-dot {
                  width: 4px;
                  height: 4px;
                  margin: 1px;
                }
              }
              
              &.type-7 {
                .poo-dot {
                  width: 12px;
                  height: 4px;
                  border-radius: 6px;
                  margin: 2px;
                  opacity: 0.7;
                }
              }
            }
            
            .option-text {
              font-size: 16px;
              font-weight: 500;
              color: #5A5A5A;
              flex: 1;
            }
          }
        }
      }
    }
    
    .bottom-actions {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-top: 30px;
      
      .cancel-btn {
        font-size: 18px;
        font-weight: 500;
        color: #999999;
        cursor: pointer;
        padding: 12px 20px;
        transition: all 0.3s ease;
        
        &:hover {
          color: #666666;
        }
      }
      
      .create-btn {
        background: #8B4513;
        border-radius: 50px;
        padding: 16px 32px;
        display: flex;
        align-items: center;
        gap: 12px;
        cursor: pointer;
        transition: all 0.3s ease;
        
        &:hover {
          background: #A0522D;
          transform: translateY(-2px);
          box-shadow: 0px 6px 20px 0px rgba(139, 69, 19, 0.3);
        }
        
        .create-text {
          font-size: 18px;
          font-weight: 600;
          color: #FFFFFF;
        }
        
        .plus-icon {
          width: 20px;
          height: 20px;
          position: relative;
          
          .line {
            position: absolute;
            background: #FFFFFF;
            border-radius: 1px;
            
            &.horizontal {
              width: 16px;
              height: 2px;
              top: 9px;
              left: 2px;
            }
            
            &.vertical {
              width: 2px;
              height: 16px;
              top: 2px;
              left: 9px;
            }
          }
        }
      }
    }
  }
}

// 响应式适配
@media (max-width: 375px) {
  .poo-tracker-create-log {
    width: 100vw;
    height: 100vh;
  }
}
</style>